package com.gis507.mapreduce.AISClassify;

import com.gis507.mapreduce.AISBean.AisClassifyBean;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

public class AISClassPartition extends Partitioner<Text, AisClassifyBean> {

    @Override
    public int getPartition(Text text, AisClassifyBean aisClassifyBean, int numPartitions) {

        //判断设置不同的分区
        if ("Fishing".equals(aisClassifyBean.getShipType())){
            //捕捞
            return 0;
        }else if ("Pilot vessel".equals(aisClassifyBean.getShipType())){
            //引航船
            return 1;
        }else if ("Search and rescue vessel".equals(aisClassifyBean.getShipType())){
            //搜救船
            return 2;
        }else if ("Tug".equals(aisClassifyBean.getShipType())){
            //拖轮
            return 3;
        }else if ("Pleasure craft".equals(aisClassifyBean.getShipType())){
            //娱乐船
            return 4;
        }else if ("WIG".equals(aisClassifyBean.getShipType())){
            //地效应船
            return 5;
        }else if ("Passenger ship".equals(aisClassifyBean.getShipType())){
            //客船
            return 6;
        }else if ("Cargo ship".equals(aisClassifyBean.getShipType())){
            //货船
            return 7;
        }else if ("Tanker".equals(aisClassifyBean.getShipType())){
            //油轮
            return 8;
        }else{
            //其他
            return 9;
        }
    }
}
